package com.five.controller.backstage;

import com.five.dao.impl.backstage.TypeDaoImpl;
import com.five.entity.backstage.Type;
import com.five.util.LayTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServlet;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/queryAllType")
//@WebServlet("/queryAll")
public class TypeController extends HttpServlet {
    @Autowired
    private TypeDaoImpl typDao = new TypeDaoImpl();

    @RequestMapping("/que")
    public LayTable queryAll(Integer page, Integer limit,Type type) {
        List<Map> maps = typDao.inqAll(page,limit,type);
        int count = typDao.getCount(type);
        LayTable table = new LayTable(count, maps);
        return table;
    }

    @RequestMapping("/delTypeId")
    public Integer delTypeId(Type type) {
        int i = typDao.delType(type);
        return i;
    }

    @RequestMapping("/updAndAdd")
    public Integer updAndAdd(Type t) {
        int i = typDao.add(t);
        return i;
    }

    @RequestMapping("bad")
    public int updata(Integer id){
        int i=typDao.bad(id);
        if (i>0){
            return i;
        }
        return -1;
    }
    @RequestMapping("good")
    public int updatagood(Integer id){
        int i=typDao.good(id);
        if (i>0){
            return i;
        }
        return -1;
    }



}





